""""
创建一个1-10的整数平方根的列表
"""
num_list = []
for item in range(1,11) :
    num_list.append(item ** 2)
print(num_list)    

"优化写法"
num_list1 = [i ** 2 for i in range(1,11)]
print(num_list1) 

"""""
取出列表中的偶数,并生成新列表
"""
z_list = list(range(1,11))
print(z_list)
o_list = []
"创建俩个列表"
for i in z_list :
    "i的范围为z_list的列表长度,进行for循环"
    "当i÷2的余数为0时,使用.append()添加到o_list"
    if i % 2 == 0 :
        o_list.append(i)
print(o_list)     

"优化写法"
z_list = list(range(1,11))
o_list = [i for i in z_list if i % 2 ==0]
print(o_list)
